Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add propagate shapes action #8044

Merged
merged 17 commits into from
Jun 28, 2024
Merged

Conversation

klakhov
Copy link
Contributor

@klakhov klakhov commented Jun 18, 2024

Motivation and context

The PR adds new action Propagate shapes that allows to propagate all filtered shapes on the current frame simultaneously

How has this been tested?

Manual testing

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • [ ] I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features

    • Introduced a new "Propagate Shapes" action to enable simultaneous propagation of filtered shapes across frames.
  • Updates

    • Updated version numbers for cvat-core to 15.0.7 and cvat-ui to 1.63.12 indicating a new release.
  • Enhancements

    • Improved annotation workflows with the addition of frame selection types and enhanced frame selection handling in the UI.
    • Conditional rendering and disabling of frame input fields based on the active frame selection type.

Copy link
Contributor

coderabbitai bot commented Jun 18, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update introduces the Propagate Shapes action in CVAT, allowing simultaneous propagation of filtered shapes across frames. Changes include adding the PropagateShapes class, related types, and enums in annotations-actions.ts, the propagateShapes function in object-utils.ts, and accommodating user interface adjustments in the annotations-actions-modal.tsx. Updates also involved incrementing version numbers for cvat-core and cvat-ui.

Changes

File Summary
changelog.d/..._propagate_shapes_simultaneously.md Introduced a documentation file summarizing the new Propagate shapes action.
cvat-core/package.json Bumped version from 15.0.6 to 15.0.7 to indicate a new feature release.
cvat-core/src/annotations-actions.ts Added the PropagateShapes class, FrameSelectionType enum, and updated BaseSingleFrameAction class.
cvat-core/src/object-utils.ts Introduced the propagateShapes function to handle shape propagation between frames.
cvat-ui/package.json Incremented version from 1.63.11 to 1.63.12 for a minor UI update.
cvat-ui/src/components/.../annotations-actions-modal.tsx Enhanced the modal to support FrameSelectionType and updated related UI/logic components.
cvat-ui/src/cvat-core-wrapper.ts Added FrameSelectionType to BaseSingleFrameAction import and updated exported entities accordingly.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI as CVAT UI
    participant Core as CVAT Core

    User->>UI: Opens annotations modal
    UI->>Core: Initialize PropagateShapes action
    Core->>UI: Provide frame selection options
    User->>UI: Select frame range and shapes to propagate
    UI->>Core: Call propagateShapes function with selected frames and shapes
    Core->>UI: Return propagated shapes data
    UI->>User: Display updated shapes on frames
Loading

Poem

🐇 In CVAT's world so bright and clear,
Frames now sync, there's no more fear,
Shapes propagate from frame to frame,
Simplifying tasks, enhancing the game.
With versions ticked up just a bit,
Shape your work with ease and wit!
🌟✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@klakhov klakhov marked this pull request as ready for review June 19, 2024 07:39
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 4139bea and fdf50da.

Files selected for processing (7)
  • changelog.d/20240619_102529_klakhov_propagate_shapes_simultaneously.md (1 hunks)
  • cvat-core/package.json (1 hunks)
  • cvat-core/src/annotations-actions.ts (6 hunks)
  • cvat-core/src/object-utils.ts (2 hunks)
  • cvat-ui/package.json (1 hunks)
  • cvat-ui/src/components/annotation-page/annotations-actions/annotations-actions-modal.tsx (9 hunks)
  • cvat-ui/src/cvat-core-wrapper.ts (3 hunks)
Files skipped from review due to trivial changes (3)
  • changelog.d/20240619_102529_klakhov_propagate_shapes_simultaneously.md
  • cvat-core/package.json
  • cvat-ui/package.json
Additional comments not posted (7)
cvat-ui/src/cvat-core-wrapper.ts (2)

40-40: Ensure that the new imports are used appropriately in the file.


99-99: The export of FrameSelectionType aligns with the new functionality added. Ensure that it is utilized where necessary.

cvat-core/src/annotations-actions.ts (2)

12-12: The introduction of PropagateShapes and FrameSelectionType is well-implemented. Ensure the new methods and properties are correctly utilized across the system to maintain consistency.

Also applies to: 41-44, 98-135


157-157: Registration of the PropagateShapes action is crucial for enabling the new functionality. Verify that this action is properly integrated into the system workflow.

Verification successful

The PropagateShapes action is registered within the cvat-core/src/annotations-actions.ts file and appears to be properly integrated into the system. The registration is found at line 157, and the class definition is also present in the same file. This confirms that the action is both defined and registered correctly.

  • cvat-core/src/annotations-actions.ts: registerAction(new PropagateShapes());
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of PropagateShapes action into the system workflow.

# Test: Search for usages of registered actions. Expect: PropagateShapes to be included.
rg --type typescript $'registerAction'

Length of output: 72



Script:

#!/bin/bash
# Description: Verify the integration of PropagateShapes action into the system workflow.

# Correct the file type and search for the registration of actions.
rg 'registerAction' --type ts

# Search for the usage of PropagateShapes in the codebase.
rg 'PropagateShapes' --type ts

Length of output: 914

cvat-core/src/object-utils.ts (1)

361-391: The implementation of propagateShapes appears robust. Ensure that the function handles edge cases and that the shapes' integrity is maintained during propagation.

cvat-ui/src/components/annotation-page/annotations-actions/annotations-actions-modal.tsx (2)

113-124: The implementation of frame selection using the FrameSelectionType is correctly handled in the reducer. Ensure that this logic correctly updates the UI based on the selected frame.


238-244: The dynamic setting of frame count in the InputNumber component is a good use of state. Ensure the frame count is accurately retrieved and updated.

cvat-core/src/object-utils.ts Outdated Show resolved Hide resolved
cvat-core/src/object-utils.ts Outdated Show resolved Hide resolved
cvat-core/src/annotations-actions.ts Outdated Show resolved Hide resolved
cvat-core/src/annotations-actions.ts Outdated Show resolved Hide resolved
cvat-core/src/annotations-actions.ts Outdated Show resolved Hide resolved
cvat-core/src/object-utils.ts Outdated Show resolved Hide resolved
@bsekachev
Copy link
Member

  • Default value for target frame "0" is useless as I am already on the same frame.
    I will propose to use the same default values as we use in default propagation functionality (+50 or -50 frames as I remember depending on possible propagation directions).

  • Also when I am on frame 0 and target frame is 0, running propagate action freezes the browser (infinite loop?)

  • Found a difference in behavior how masks are propagated using default propagation and actions. Example:

    • First frame is 1000x1000, mask is on [900:1000, 900:1000].
    • Second frame is 500x500.
    • Propagate, using classic way: empty masks are created at top left corner. But export to Segmentation mask format works.
    • Propagate, using action: masks are copied, but outside of the frame. As result export to Segmentation mask format does not work.

I am not sure, that copies in both cases are correct, but the second case creates more issues, not allowing to export task.

image

@bsekachev
Copy link
Member

Also, please, add tests to cover found issues.

@codecov-commenter
Copy link

codecov-commenter commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 87.50000% with 7 lines in your changes missing coverage. Please review.

Project coverage is 83.63%. Comparing base (78fa7cf) to head (b56bbf7).
Report is 11 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #8044      +/-   ##
===========================================
+ Coverage    83.62%   83.63%   +0.01%     
===========================================
  Files          383      383              
  Lines        40439    40503      +64     
  Branches      3815     3831      +16     
===========================================
+ Hits         33817    33875      +58     
- Misses        6622     6628       +6     
Components Coverage Δ
cvat-ui 79.67% <87.50%> (+0.08%) ⬆️
cvat-server 87.25% <ø> (-0.05%) ⬇️

@klakhov klakhov requested a review from azhavoro as a code owner June 25, 2024 09:15
@klakhov klakhov requested a review from Marishka17 as a code owner June 25, 2024 09:16
@klakhov
Copy link
Contributor Author

klakhov commented Jun 25, 2024

  • Default value for target frame "0" is useless as I am already on the same frame.

In default propagate we use 0and lastFrame, so Ive added last frame as default

  • Also when I am on frame 0 and target frame is 0, running propagate action freezes the browser (infinite loop?)

Fixed

  • Found a difference in behavior how masks are propagated using default propagation and actions.

Fixed as discussed (cropMask if needed in MaskShape constructor)

Also added tests for default propagate aciton, action on current frame and mask case

@bsekachev
Copy link
Member

bsekachev commented Jun 26, 2024

Extra file?
image

Copy link

sonarcloud bot commented Jun 26, 2024

Copy link
Member

@bsekachev bsekachev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@klakhov klakhov merged commit b6159aa into develop Jun 28, 2024
33 checks passed
@cvat-bot cvat-bot bot mentioned this pull request Jul 2, 2024
@bsekachev bsekachev deleted the kl/propagate-shapes-simultaneously branch July 8, 2024 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants